<?php
namespace app\index\service;

class JdUnionService
{
    public function formatData($data)
    {
        if (!$data) {
            return [];
        }
        $result = [];
        foreach ($data as $key => $val) {
            $result[] = [
                'skuId' => $val['skuId'], // 商品ID
                'skuName' => $val['skuName'], // 商品名称
                'spuid' => $val['spuid'], // spuid，其值为同款商品的主skuid
                'cid1' => $val['categoryInfo']['cid1'], // 一级分类ID
                'cid1Name' => $val['categoryInfo']['cid1Name'], // 一级分类名称
                'cid2' => $val['categoryInfo']['cid2'], // 二级分类ID
                'cid2Name' => $val['categoryInfo']['cid2Name'], // 二级分类名称
                'cid3' => $val['categoryInfo']['cid3'], // 三级分类ID
                'cid3Name' => $val['categoryInfo']['cid3Name'],//三级分类名称
                'comments' => $val['comments'], // 评论数
                'commission' => $val['commissionInfo']['commission'], // 佣金
                'commissionShare' => $val['commissionInfo']['commissionShare'], // 佣金比例
                'couponCommission' => $val['commissionInfo']['couponCommission'],//券后佣金，（促销价-优惠券面额）*佣金比例
                'endTime' => $val['commissionInfo']['endTime'],//计划结束时间
                'isLock' => $val['commissionInfo']['isLock'], // 是否锁定佣金比例
                'plusCommissionShare' => $val['commissionInfo']['plusCommissionShare'],//plus佣金比例，plus用户购买推广者能获取到的佣金比例
                'startTime' => $val['commissionInfo']['startTime'],// 计划开始时间
                'deliveryType' => $val['deliveryType'], // 京东配送 1：是，0：不是
                'goodCommentsShare' => $val['goodCommentsShare'], // 商品好评率
                'inOrderCount30Days' => $val['inOrderCount30Days'], // 30天引单数量
                'inOrderCount30DaysSku' => $val['inOrderCount30DaysSku'],// 30天引单数量(sku维度)
                'materialUrl' => $val['materialUrl'],//商品落地页
                'owner' => $val['owner'],// 是否自营
                'historyPriceDay' => isset($val['priceInfo']['historyPriceDay']) ? $val['priceInfo']['historyPriceDay'] : '', // 历史最低价天数（例：当前券后价最近180天最低）
                'lowestCouponPrice' => $val['priceInfo']['lowestCouponPrice'], // 券后价（有无券都返回此字段）
                'lowestPrice' => $val['priceInfo']['lowestPrice'], // 促销价
                'lowestPriceType' => $val['priceInfo']['lowestPriceType'],//促销价类型，1：无线价格；2：拼购价格； 3：秒杀价格
                'price' => $val['priceInfo']['price'],//商品价格
            ];
        }
        return $result;
    }

}